# Copyright 2016 Robot Locomotion Group @ CSAIL. All rights reserved.
#
# All components of Drake are licensed under the BSD 3-Clause License.
# See LICENSE.TXT or https://drake.mit.edu/ for details.

load("@rules_cc//cc:cc_library.bzl", "cc_library")

licenses(["notice"])  # BSD-3-Clause

package(default_visibility = ["//visibility:private"])

cc_library(
    name = "config",
    srcs = ["SuiteSparse_config/SuiteSparse_config.c"],
    hdrs = ["SuiteSparse_config/SuiteSparse_config.h"],
    strip_include_prefix = "SuiteSparse_config",
    visibility = ["//visibility:public"],
    defines = select({
        "@platforms//os:windows": ["NTIMER"],
        "//conditions:default": [],
    }),
)

# The header for libamd.
cc_library(
    name = "amd_hdrs",
    hdrs = [
        "AMD/Include/amd_internal.h",
        "AMD/Include/amd.h",
    ],
    strip_include_prefix = "AMD/Include",
    deps = [
        ":config",
    ],
)

# The libamd sources are compiled twice, once as 32-bit and once as 64-bit.
_AMD_SRCS = glob(
    ["AMD/Source/amd_*.c"],
    exclude = ["AMD/Source/amd_l*.c"],
    allow_empty = False,
)

cc_library(
    name = "amd",
    srcs = _AMD_SRCS,
    copts = ["-DDLONG"],
    deps = [":amd_hdrs"],
    visibility = ["//visibility:public"],
)
